package ViewPackage;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MainMenu implements MouseListener{
	
	//Ez a class is egy GameCanvasra rajzol
	private GameCanvas gc=null;
	
	private MainMenuButton btn1;
	//A kirajzolando szoveg
	private String text1=new String("");
	private String text2=new String("");
	private String text3=new String("");
	
	MainMenu(GameCanvas gc){
		this.gc=gc;
		gc.addMouseListener(this);
		
		
		double width=gc.getPreferredSize().getWidth();
		double height=gc.getPreferredSize().getHeight();
		
		
		btn1=new MainMenuButton((int)Math.round(width*(3.0/8.0)),
				(int)Math.round(height*(13.0/16.0)),
				(int)Math.round(width/4.0),
				(int)Math.round(height/16.0),
				new String("       Start       "));
		
		//Elore rajzolas a gameCanvasra
	
		
	}
	public void setText1(String text){
		if(text!=null){
			this.text1=text;
		}
		this.draw();
		
	}
	public void setText2(String text){
		if(text!=null){
			this.text2=text;
		}
		this.draw();
		
	}
	public void setText3(String text){
		if(text!=null){
			this.text3=text;
		}
		this.draw();
		
	}
	
	//Kirajzolas a GameCanvasra
	public void draw(){
		Graphics g=gc.getImage();
		if(g==null)return;
		
		//Egyszerusites celjabol
		int width=(int)Math.round(gc.getPreferredSize().getWidth());
		int height=(int)Math.round(gc.getPreferredSize().getHeight());
		
		
		g.setColor(Color.green);
		g.fillRect(0,0,width,height);
		
		g.setColor(Color.getHSBColor((float)(14/240.0), (float)(99/240.0), (float)(128/240.0)));
		g.fillRect(50,50,width-100,height-250);
		
		btn1.draw(g);
		
		g.setColor(Color.white);
		Font font = new Font("Arial", Font.BOLD, 28);
		g.setFont(font);
		g.drawString(text1,75,100);
		font = new Font("Arial", Font.BOLD, 26);
		g.setFont(font);
		g.drawString(text2,75,200);
		g.drawString(text3,75,300);
		
		gc.reDraw();
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		//Csak akkor szamit az egerkattintas ha a gombon tortent
		if(btn1.isClicked(e)){
			//A main ertesitese, hogy indulhat a jatek
			synchronized(Main.syncobj){
				Main.syncobj.notify();
			}
		}
	}
		
		

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void setButtonText(String text){
		btn1.setText(text);
		this.draw();
	}
}
